<?php

class User_Form_ChangePassword extends Custom_Form
{
	public function init()
    {
		$translate = Zend_Registry::get('translate');
		$this->setTranslator($translate);
		$passwordConfirmation = new Custom_Validate_PasswordConfirmation();
		$currentPassword = new Custom_Validate_CurrentPassword();
        $this->setName("change_password");
        $this->setMethod('post');

		$this->addElement('password', 'current_password', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(8, 50)),
				array('Alnum'),
				$currentPassword
			),
            'required'   => true,
            'label'      => __('Current Password').':',
        ));

        $this->addElement('password', 'password', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(8, 50)),
				array('Alnum'),
			),
            'required'   => true,
            'label'      => __('New Password').':',
        ));

		$this->addElement('password', 'password_confirm', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(8, 50)),
				array('Alnum'),
				$passwordConfirmation
            ),
            'required'  => true,
			'ignore'	=> true,
            'label'     => __('Confirm New Password').':',
        ));

		$this->addElement('submit', 'save', array(
            'required' => false,
            'ignore'   => true,
            'label'    => __('Save'),
        ));

		$this->save->removeDecorator('label');

		$this->current_password->addErrorMessage('ERR_INVALID_CURRENT_PASSWORD');
		$this->password->addErrorMessage('ERR_LOGIN_PASSWORD_REQUIRED');
		$this->password_confirm->addErrorMessage('ERR_INVALID_CONFIRM_PASSWORD');
    }
}